
import { useState, useEffect } from 'react'

const useAuth = () =>{
  const [isLogin] = useState(sessionStorage.getItem('token')?true:false)
  return {isLogin}
}

// 初始化数据
const useInit = (fn: any) => {
  const [list, setList] = useState([])
  useEffect(() => {

    fn().then((res:any) => {
      setList(res.data)


    })
  }, [])

  return [list]

}
// 给表格添加Key值
const useKey = (arr: any) => {
  arr.forEach((item: any) => {
    item.key = item.id
  })
  return arr
}
export {
  useAuth,
  useInit,
  useKey

}


